package com.shkco.feign;

import com.shkco.domain.User;
import com.shkco.result.JSONResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class UserServiceFallbackFactory implements FallbackFactory<UserService> {
    @Override
    public UserService create(Throwable throwable) {
        return new UserService() {
            @Override
            public JSONResult update(User user) {
                return JSONResult.error("当前服务不可用，请稍后重试！","-1");
            }

            @Override
            public User findById(Long id) {
                return new User(null,"当前服务不可用",null);
            }

        };
    }
}
